﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FreedomX2.Core.Encrypt
{
    public static class EncryptEx
    {
        public enum CryptType
        {
            DouCrypt,
            CAJCrypt,
            MD5byWeb,
            MD5by16,
            MD5by32
        }

        public static string Encrypt(this string str, CryptType ct)
        {
            if (ct == CryptType.CAJCrypt)
                return DEncrypt.DESEncode(str, Envior.Ment.ENCRYPTSTR);
            else if (ct == CryptType.DouCrypt)
                return DEncrypt.Encode(str, Envior.Ment.ENCRYPTSTR);
            else if (ct == CryptType.MD5byWeb)
                return DEncrypt.GetMD5ByWeb(str);
            else if (ct == CryptType.MD5by16)
                return DEncrypt.GetMD5ByBytes(str);
            else if (ct == CryptType.MD5by32)
                return DEncrypt.MD5Convert32to16(str);
            else
                return "crypt type error!";

        }
        public static string Encrypt(this string str)
        {
            return DEncrypt.DESEncode(str, Envior.Ment.ENCRYPTSTR);
        }
        public static string Decrypt(this string str)
        {
            return DEncrypt.DESDecode(str, Envior.Ment.ENCRYPTSTR);
        }
        public static string Decrypt(this string str, CryptType ct)
        {
            if (ct == CryptType.CAJCrypt)
                return DEncrypt.DESDecode(str, Envior.Ment.ENCRYPTSTR);
            else if (ct == CryptType.DouCrypt)
                return DEncrypt.Decode(str, Envior.Ment.ENCRYPTSTR);
            else
                return "crypt type error!";
        }
    }
}
